﻿#!/usr/bin/env python3

def funca(a=[]):
    a.append(1)
    print(a)

def funcb(a=None):
    if a==None:
        a=[]
    a.append(1)
    print(a)

def main():
    '''
function default parameter -
python中function是一等object, 即函数是一种对象, 原文如下,
Default parameter values are evaluated from left to right when the function 
definition is executed. This means that the expression is evaluated once, when 
the function is defined, and that the same “pre-computed” value is used for 
each call.
即function object的default param在其定义时就已经计算好,并在随后的所有调用中使用该"同一个"值.
当该值是immutable类型还好说,而当该值是mutable情况下,就很容易产生误解, 因为其效果与C++等的效果不尽相同
    '''
    print(main.__doc__)
    print("a:")
    funca()
    funca()
    funca()
    print("b:")
    funcb()
    funcb()
    funcb()


if __name__=='__main__':
    main()
